
#ifndef __class_str_RGB
#define __class_str_RGB
class str_RGB{
public:
  void packRGB(uint8_t,uint8_t,uint8_t);
  void unpackRGB(float rgbf);
  float getRGBf() {return rgbf;}
  uint8_t getR() {return r;}
  uint8_t getG() {return g;}
  uint8_t getB() {return b;}
private:
  uint8_t r;
    uint8_t g;
    uint8_t b;
    float rgbf;
    uint32_t rgb;
};
inline void str_RGB::packRGB(uint8_t ri,uint8_t gi,uint8_t bi)
{
  uint32_t rgb = ((uint32_t)ri << 16 | (uint32_t)gi << 8 | (uint32_t)bi);
  r = ri;g= gi;b = gi;
  rgbf = *reinterpret_cast<float*>(&rgb);
}
inline void str_RGB::unpackRGB(float rgbin)
{
  rgbf = rgbin;
  rgb = *reinterpret_cast<int*>(&rgbf);
  r = (rgb >> 16) & 0x0000ff;
  g = (rgb >> 8)  & 0x0000ff;
  b = (rgb)       & 0x0000ff;
}
#endif
